#pragma once


namespace SD_Tools
{
	class Vector2
	{
	private:
	public:
		union
		{
			struct
			{
				float x;
				float y;
			};
			float RawData[2];
		};
	private:
	public:
		Vector2() {};
		Vector2(float x, float y): x(x), y(y) {};
		Vector2(int x, int y): x((float) x), y((float) y) {};
		void Clear();
		float Magnitude();
		float MagnitudeSqr();
		void Subtract(Vector2& Vec);
		void Add(Vector2& Vec);
		void Multiply(float Mul);
		void Turn(float Angle);
		void Turn(float Angle, Vector2& Origin);
	};

	void Vector2::Clear()
	{
		this->x = 0.0f;
		this->y = 0.0f;
	}

	float Vector2::Magnitude()
	{
		return sqrtf(x*x + y*y);
	}

	float Vector2::MagnitudeSqr()
	{
		return (x*x + y*y);
	}

	void Vector2::Subtract( Vector2& Vec )
	{
		this->x -= Vec.x;
		this->y -= Vec.y;
	}

	void Vector2::Add( Vector2& Vec )
	{
		this->x += Vec.x;
		this->y += Vec.y;
	}

	void Vector2::Multiply( float Mul )
	{
		this->x *= Mul;
		this->y *= Mul;
	}

	void Vector2::Turn( float Angle )
	{
		float tx = x;
		float ty = y;
		x = tx*cosf(Angle) - ty*sinf(Angle);
		y = tx*sinf(Angle) + ty*cosf(Angle);
	}

	void Vector2::Turn( float Angle, Vector2& Origin )
	{
		float tx = x-Origin.x;
		float ty = y-Origin.y;
		x = tx*cosf(Angle) - ty*sinf(Angle) + Origin.x;
		y = tx*sinf(Angle) + ty*cosf(Angle) + Origin.y;
	}

	class Ray2
	{
	private:
	public:
	private:
	public:
	};

	class Plane2
	{
	private:
	public:
	private:
	public:
	};

	class Angle2
	{
	private:
	public:
	private:
	public:
	};

	class Rectangle2
	{
	private:
	public:
		float x;
		float y;
		float w;
		float h;
	private:
	public:
		Rectangle2() {};
		Rectangle2(float x, float y, float w, float h): x(x), y(y), w(w), h(h) {};
		Rectangle2(int x, int y, int w, int h): x((float) x), y((float) y), w((float) w), h((float) h) {};
		bool IsPointIn(Vector2& Point);
	};

	bool Rectangle2::IsPointIn( Vector2& Point )
	{
		return (Point.x >= this->x && Point.x < this->x+this->w && Point.y >= this->y && Point.y < this->y+this->h);
	}
}